package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"teacher1/api/internal/config"
	"teacher1/api/internal/middleware"
	"teacher1/studentrpc/studentrpcclient"
	"teacher1/teacherrpc/teacherrpcclient"
)

type ServiceContext struct {
	Config          config.Config
	StudentRpc      studentrpcclient.Studentrpc
	TeacherRpc      teacherrpcclient.Teacherrpc
	LoginMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:          c,
		StudentRpc:      studentrpcclient.NewStudentrpc(zrpc.MustNewClient(c.StudentRpc)),
		TeacherRpc:      teacherrpcclient.NewTeacherrpc(zrpc.MustNewClient(c.TeacherRpc)),
		LoginMiddleware: middleware.NewLoginMiddleware().Handle,
	}
}
